﻿
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NC.Infrastructure.Cache
{
    /// <summary>
    /// 缓存操作管理器
    /// </summary>
    public class CacheManager
    {
        private static readonly RuntimeMemoryCacheProvider RuntimeMemoryCacheProvider;

        static CacheManager()
        {
            RuntimeMemoryCacheProvider = new RuntimeMemoryCacheProvider();
        }
        /// <summary>
        /// 获取指定区域的缓存执行者实例
        /// </summary>
        public static ICache GetCacher(string region)
        {
            ICache cache;
            cache = RuntimeMemoryCacheProvider.GetCache(region);
            return cache;
        }

        /// <summary>
        /// 获取指定类型的缓存执行者实例
        /// </summary>
        /// <param name="type">类型实例</param>
        public static ICache GetCacher(Type type)
        {
            return GetCacher(type.FullName);
        }

        /// <summary>
        /// 获取指定类型的缓存执行者实例
        /// </summary>
        public static ICache GetCacher<T>()
        {
            return GetCacher(typeof(T));
        }
    }
}
